home *** CD-ROM | disk | FTP | other *** search
/ ADA Programming Guide / ADA Programming Guide.iso / ada_gnu / adainc / s-imgdec.ads < prev    next >
Text File  |  1996-01-30  |  4KB  |  76 lines

  1. ------------------------------------------------------------------------------
  2. --                                                                          --
  3. --                         GNAT RUNTIME COMPONENTS                          --
  4. --                                                                          --
  5. --                    S Y S T E M . I M G _ D E C I M A L                   --
  6. --                                                                          --
  7. --                                 S p e c                                  --
  8. --                                                                          --
  9. --                            $Revision: 1.2 $                              --
  10. --                                                                          --
  11. --           Copyright (c) 1992,1993,1994 NYU, All Rights Reserved          --
  12. --                                                                          --
  13. -- The GNAT library is free software; you can redistribute it and/or modify --
  14. -- it under terms of the GNU Library General Public License as published by --
  15. -- the Free Software  Foundation; either version 2, or (at your option) any --
  16. -- later version.  The GNAT library is distributed in the hope that it will --
  17. -- be useful, but WITHOUT ANY WARRANTY;  without even  the implied warranty --
  18. -- of MERCHANTABILITY  or  FITNESS FOR  A PARTICULAR PURPOSE.  See the  GNU --
  19. -- Library  General  Public  License for  more  details.  You  should  have --
  20. -- received  a copy of the GNU  Library  General Public License  along with --
  21. -- the GNAT library;  see the file  COPYING.LIB.  If not, write to the Free --
  22. -- Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.        --
  23. --                                                                          --
  24. ------------------------------------------------------------------------------
  25.  
  26. --  Image for decimal fixed types where the size of the corresponding integer
  27. --  type does not exceed Integer'Size (also used for Text_IO.Decimal_IO output)
  28.  
  29. package System.Img_Decimal is
  30. pragma Preelaborate (Img_Decimal);
  31.  
  32.    function Image_Decimal
  33.      (V     : Integer;
  34.       S     : access String;
  35.       Scale : Integer)
  36.       return  Natural;
  37.    --  Compute 'Image of V, the integer value (in units of delta) of a decimal
  38.    --  type whose Scale is as given. The image is stored in S (1 .. N), where
  39.    --  N is the returned result. The image is given by the rules in RM 3.5(34)
  40.    --  for fixed-point type image functions.
  41.  
  42.    procedure Set_Image_Decimal
  43.      (V     : Integer;
  44.       S     : out String;
  45.       P     : in out Natural;
  46.       Scale : Integer;
  47.       Fore  : Natural;
  48.       Aft   : Natural;
  49.       Exp   : Natural);
  50.    --  Sets the image of V, where V is the integer value (in units of delta)
  51.    --  of a decimal type with the given Scale, starting at S (P + 1), updating
  52.    --  P to point to the last character stored, the caller promises that the
  53.    --  buffer is large enough and no check is made for this. Constraint_Error
  54.    --  will not necessarily be raised if this requirement is violated, since
  55.    --  it is perfectly valid to compile this unit with checks off. The Fore,
  56.    --  Aft and Exp values can be set to any valid values for the case of use
  57.    --  by Text_IO.Decimal_IO.
  58.  
  59.    procedure Set_Decimal_Digits
  60.      (Digs  : in out String;
  61.       NDigs : Natural;
  62.       S     : out String;
  63.       P     : in out Natural;
  64.       Scale : Integer;
  65.       Fore  : Natural;
  66.       Aft   : Natural;
  67.       Exp   : Natural);
  68.    --  This procedure has the same semantics as Set_Image_Decimal, except that
  69.    --  the value in Digs (1 .. NDigs) is given as a string of decimal digits
  70.    --  preceded by either a minus sign or a space (i.e. the integer image of
  71.    --  the value in units of delta). The call may destroy the value in Digs,
  72.    --  which is why Digs is in-out (this happens if rounding is required).
  73.    --  Set_Decimal_Digits is shared by all the decimal image routines.
  74.  
  75. end System.Img_Decimal;
  76.